/*
 * 饿汉模式
 *
 * */
class Singlton{
    private void Singlton(){

    }
    private static Singlton singlton=new Singlton();
    public static Singlton getSinglton(){
        return singlton;
    }
}
//这里将构造方法设置成private,是为了防止别人不小心new了对象.
public class demon1 {
    public static void main(String[] args) {
        Singlton s1=Singlton.getSinglton();
        Singlton s2=Singlton.getSinglton();
        System.out.println(s1==s2);
    }

}
